#ifndef POSVIEW_H
#define POSVIEW_H

#include <QGraphicsView>
#include <QGraphicsScene>
#include <QWheelEvent>
#include <QPointF>
#include <posfileinfo.h>
#include <QMap>
#include <QGraphicsEllipseItem>
#include <QGraphicsTextItem>

class PosView : public QGraphicsView
{
    Q_OBJECT

public:   
    PosView(QGraphicsScene *scene, QWidget *parent = nullptr);
    PosView(QWidget *parent = nullptr);
    ~PosView();

    typedef enum show_type{
        SHOW_TYPE_NONE = 0,
        SHOW_TYPE_FIX,
        SHOW_TYPE_FLOAT,
        SHOW_TYPE_SIGNLE,
        SHOW_TYPE_ALL,
    }SHOW_TYPE;

    void wheelEvent(QWheelEvent *event) override;

    void mouseMoveEvent(QMouseEvent *event) override;

    void dragEnterEvent(QDragEnterEvent *event) override;

    void dropEvent(QDropEvent *event) override;

    void setScaleStep(qreal x, qreal y);

    bool readPosFromFile(QString& fn);

    bool updateShow(const QString& name);

    void cleanShow(void);

    void showType(SHOW_TYPE type);

    QString& getCurrentShowFileName(void);

    bool deletePointByFile(QString& fn);

    bool deletePoints(void);

    bool showNumber(bool);

    QMap<QString, PosFileInfo>& getPos(void);

    QString getMouseUpMsg(void);

signals:
    void fileListChange(bool);
    void sendMsg(const QString& msg);

private:
    qreal xSaleStep;
    qreal ySaleStep;
    qreal  xOld;
    qreal  yOld;
    QPointF mouseCurrentPoint;

    SHOW_TYPE current_show_type;

    QString currenShowFileName;

    QMap<QString, PosFileInfo> posList;  //fileName, PosFileInfo
    QList<QGraphicsEllipseItem*> ellipseItems;
    QList<QGraphicsTextItem*> textItems;

    bool numShowEnable;

};

#endif // POSVIEW_H
